


    <!--banner-->
    <div class="banner">
    	<ul class="ban-ul1">
            <?php
            foreach($pageproduct as $key=>$value){
                if($value['type']==1){
                    echo '<li><a href="'.Url::base().'index.php/product/detail?id='.$value['productId'].'"><img src="'.Url::base().'uploads/'.$value['img'].'" /></a></li>';
                }

            }
            ?>


        </ul>
        <div class="ban-box w1200">
        	<ol class="ban-ol1">
            	<li class="current"></li>
            	<li></li>
            	<li></li>
            	<li></li>
               	<div style="clear:both;"></div>
            </ol>
        </div>
    </div>

    <!--热门推荐-->
    <div class="hot-recommend w1200">
    	<h3>热门推荐</h3>
        <ul class="">
            <?php

            $count = 0;
            $li = 'ys1 ys2';
            $width = '';
            foreach($pageproduct as $key=>$value){

                if($value['type']==2){
                if($count ==4){

                    $li='ys1 ys2';
                }else{
                    $width = '';
                }

                if($count ==7||$count==3){
                    $width='style=" width:298px;"';
                }else{
                    $width = '';
                }
                $count++;
                    ?>

                    <li class="<?php echo $li;?>" <?php echo $width;?>>
                        <p><?php echo $value['content'];?></p>
                        <a href="#" class="ys2-a1" style="margin-bottom:25px;"><?php echo $value['content'];?></a>
                        <a href="#"><img width="220" height="120" src="<?php echo Url::base(); ?>uploads/<?php echo$value['img'];?>" /></a>
                    </li>
                <?php } }?>



            <div style="clear:both;"></div>
        </ul>
    </div>
<?php
$productpageset= new productpageset();
$pageproduct = $get->getCache('pageproduct');
if($pageproduct == ''){
    $pageproduct = $productpageset->getAll();
    $get->setCache('pageproduct',$pageproduct);


}
$productId= array();
foreach($pageproduct as $key=>$value){
    $productId[$key] =$value['productId'];
//        array_unique
}
$productId = array_unique($productId);
?>
    <!--商品内容页面-->
    <div class="shopping-content w1200">
    	<div class="sp-con-info">
        	<h3 class="sp-info-tit"><span>1F</span></h3>
        	<div class="sp-info-l f-l">
                <?php

                $labels = '';
 foreach($pageproduct as $key=>$value){
                $labels = $value['content'];

                if($value['type']==4){

                    $result = ($value['content']);
                ?>
            	<a href="<?php echo Url::base(); ?>index.php/product/detail?id=<?php echo$value['productId'];?>"><img width=231 height=464 src="<?php echo Url::base(); ?>uploads/<?php echo $value['img'];?>" /></a>

                <?php
            }}

                $list = (explode(",", $result));

            ?>


                <div class="sp-l-b">

                              <?php

                              require_once ('application/classes/api/product.php');
                              require_once ('application/classes/api/label.php');
                              $entity = new label();
                              $product = new product();
 foreach($list as $key=>$value){

     $label = $get->getCache('label'.$value);

     if($label == ''){
         $parm['id'] =$value;
         $label = $entity ->detail($parm);

         $get->setCache('label'.$value,$label);


     }



    ?>
                	<a href="<?php echo Url::base(); ?>index.php/label/detail?id=<?php echo $value; ?>"><?php echo  $label[0]['name']; ?></a>


                    <?php }?>
                	
                </div>
            </div>
        	<ul class="sp-info-r f-r">

                <?php

                foreach($pageproduct as $key=>$value){


                if($value['type']==3) {
                    $getresult = $get->getCache('productId'.$value['productId']);

                    if($getresult==''){
                        $parm['id']=$value['productId'];
                        $getresult = $product->getByProductId($parm);



                    }
                    $getresult[0]['mainpic'] = $value['img'];

            ?>

                    <li>
                        <div class="li-top">
                                 <a href="<?php echo Url::base(); ?>index.php/product/detail?id=<?php  echo $getresult[0]['productId'];?>" class="li-top-tu"><img width="95" height="110" src="<?php echo Url::base(); ?>uploads/<?php echo$getresult[0]['mainpic'];?>" /></a>
                             <p class="jiage"><span class="sp1">￥<?php echo $getresult[0]['pricedefault'];?></span><span class="sp2">￥<?php echo $getresult[0]['OriginalPrice'];?></span></p>
                        </div>
                        <p class="miaoshu"><?php echo $getresult[0]['title'];?></p>
                        <div class="li-md">
                            <div class="md-l f-l">
                                <p class="md-l-l f-l" ap="">1</p>
                                <div class="md-l-r f-l">
                                    <a href="JavaScript:;" class="md-xs" at="">∧</a>
                                    <a href="JavaScript:;" class="md-xx" ab="">∨</a>
                                </div>
                                <div style="clear:both;"></div>
                            </div>
                            <div class="md-r f-l">
                                <button class="md-l-btn1" attr="<?php echo $getresult[0]['id'];?>">立即购买</button>
                                <button class="md-l-btn2">加入购物车</button>
                            </div>
                            <div style="clear:both;"></div>
                        </div>
                        <p class="pingjia"><?php echo $getresult[0]['replying'];?>评价</p>

                    </li>
               <? }

                }
?>


            </ul>
            <div style="clear:both;"></div>
        </div>
        <div class="sp-con-info">
        	<h3 class="sp-info-tit"><span style="color:#F56904;">2F</span></h3>
            <div class="sp-info-l f-l">
                <?php

                $labels = '';
                foreach($pageproduct as $key=>$value){
                    $labels = $value['content'];

                    if($value['type']==5){
                        $result = ($value['content']);
                        ?>
                        <a href="<?php echo Url::base(); ?>index.php/product/detail?id=<?php echo$value['productId'];?>"><img width=231 height=464 src="<?php echo Url::base(); ?>uploads/<?php echo$value['img'];?>" /></a>

                        <?php
                    }}
                $list = explode(',', $result);
                ?>

                <div class="sp-l-b">

                    <?php

                    require_once ('application/classes/api/product.php');
                    require_once ('application/classes/api/label.php');
                    $entity = new label();
                    $product = new product();
                    foreach($list as $key=>$value){
                        $label = $get->getCache('label'.$value);
                        if($label == ''){
                            $parm['id'] =$value;
                            $label = $entity ->detail($parm);

                            $get->setCache('label'.$value,$label);


                        }



                        ?>
                        <a href="<?php echo Url::base(); ?>index.php/label/detail?id=<?php echo $value; ?>"><?php echo  $label[0]['name']; ?></a>


                    <?php }?>

                </div>
            </div>
        	<ul class="sp-info-r f-r">
                <?php

                foreach($pageproduct as $key=>$value){


                    if($value['type']==6) {
                        $getresult = $get->getCache('productId'.$value['productId']);

                        if($getresult==''){
                            $parm['id']=$value['productId'];
                            $getresult = $product->getByProductId($parm);



                        }
$getresult[0]['mainpic'] = $value['img'];

                        ?>

                        <li>
                            <div class="li-top">
                                <a href="<?php echo Url::base(); ?>index.php/product/detail?id=<?php  echo $getresult[0]['productId'];?>" class="li-top-tu"><img width="95" height="110" src="<?php echo Url::base(); ?>uploads/<?php echo$getresult[0]['mainpic'];?>" /></a>
                                <p class="jiage"><span class="sp1">￥<?php echo $getresult[0]['pricedefault'];?></span><span class="sp2">￥<?php echo $getresult[0]['OriginalPrice'];?></span></p>
                            </div>
                            <p class="miaoshu"><?php echo $getresult[0]['title'];?></p>
                            <div class="li-md">
                                <div class="md-l f-l">
                                    <p class="md-l-l f-l" ap="">1</p>
                                    <div class="md-l-r f-l">
                                        <a href="JavaScript:;" class="md-xs" at="">∧</a>
                                        <a href="JavaScript:;" class="md-xx" ab="">∨</a>
                                    </div>
                                    <div style="clear:both;"></div>
                                </div>
                                <div class="md-r f-l">
                                    <button class="md-l-btn1" attr="<?php echo $getresult[0]['id'];?>">立即购买</button>
                                    <button class="md-l-btn2">加入购物车</button>
                                </div>
                                <div style="clear:both;"></div>
                            </div>
                            <p class="pingjia"><?php echo $getresult[0]['replying'];?>评价</p>

                        </li>
                    <? }

                }
                ?>



            </ul>
            <div style="clear:both;"></div>
        </div>
        <div class="sp-con-info">
            <h3 class="sp-info-tit"><span style="color:#F56904;">3F</span></h3>
            <div class="sp-info-l f-l">
                <?php

                $labels = '';
//                print_r($pageproduct);
                foreach($pageproduct as $key=>$value){
                    $labels = $value['content'];

                    if($value['type']==5){
                        ?>
                        <a href="<?php echo Url::base(); ?>index.php/product/detail?id=<?php echo$value['productId'];?>"><img width=231 height=464 src="<?php echo Url::base(); ?>uploads/<?php echo$value['img'];?>" /></a>

                        <?php
                        break;
                    }}

                $list = explode(',', $labels);
                ?>

                <div class="sp-l-b">

                    <?php

                    require_once ('application/classes/api/product.php');
                    require_once ('application/classes/api/label.php');
                    $entity = new label();
                    $product = new product();
                    foreach($list as $key=>$value){
                        $label = $get->getCache('label'.$value);
                        if($label == ''){
                            $parm['id'] =$value;
                            $label = $entity ->detail($parm);

                            $get->setCache('label'.$value,$label);


                        }



                        ?>
                        <a href="<?php echo Url::base(); ?>index.php/label/detail?id=<?php echo $value; ?>"><?php echo  $label[0]['name']; ?></a>


                    <?php }?>

                </div>
            </div>
            <ul class="sp-info-r f-r">
                <?php

                foreach($pageproduct as $key=>$value){


                    if($value['type']==7) {
                        $getresult = $get->getCache('productId'.$value['productId']);

                        if($getresult==''){
                            $parm['id']=$value['productId'];
                            $getresult = $product->getByProductId($parm);



                        }

$getresult[0]['mainpic'] = $value['img'];
                        ?>

                        <li>
                            <div class="li-top">
                                <a href="<?php echo Url::base(); ?>index.php/product/detail?id=<?php  echo $getresult[0]['productId'];?>" class="li-top-tu"><img width="95" height="110" src="<?php echo Url::base(); ?>uploads/<?php echo$getresult[0]['mainpic'];?>" /></a>
                               <p class="jiage"><span class="sp1">￥<?php echo $getresult[0]['pricedefault'];?></span><span class="sp2">￥<?php echo $getresult[0]['OriginalPrice'];?></span></p>
                            </div>
                            <p class="miaoshu"><?php echo $getresult[0]['title'];?></p>
                            <div class="li-md">
                                <div class="md-l f-l">
                                    <p class="md-l-l f-l" ap="">1</p>
                                    <div class="md-l-r f-l">
                                        <a href="JavaScript:;" class="md-xs" at="">∧</a>
                                        <a href="JavaScript:;" class="md-xx" ab="">∨</a>
                                    </div>
                                    <div style="clear:both;"></div>
                                </div>
                                <div class="md-r f-l">
                                    <button class="md-l-btn1" attr="<?php echo $getresult[0]['id'];?>">立即购买</button>
                                    <button class="md-l-btn2">加入购物车</button>
                                </div>
                                <div style="clear:both;"></div>
                            </div>
                            <p class="pingjia"><?php echo $getresult[0]['replying'];?>评价</p>

                        </li>
                    <? }

                }
                ?>



            </ul>
            <div style="clear:both;"></div>
        </div>

        <div class="sp-con-info">
            <h3 class="sp-info-tit"><span style="color:#F56904;">4F</span></h3>
            <div class="sp-info-l f-l">
                <?php

                $labels = '';
                foreach($pageproduct as $key=>$value){
                    $labels = $value['content'];

                    if($value['type']==5){
                        ?>
                        <a href="<?php echo Url::base(); ?>index.php/product/detail?id=<?php echo$value['productId'];?>"><img width=231 height=464 src="<?php echo Url::base(); ?>uploads/<?php echo$value['img'];?>" /></a>

                        <?php
                        break;
                    }}
                $list = explode(',', $labels);
                ?>

                <div class="sp-l-b">

                    <?php

                    require_once ('application/classes/api/product.php');
                    require_once ('application/classes/api/label.php');
                    $entity = new label();
                    $product = new product();
                    foreach($list as $key=>$value){
                        $label = $get->getCache('label'.$value);
                        if($label == ''){
                            $parm['id'] =$value;
                            $label = $entity ->detail($parm);

                            $get->setCache('label'.$value,$label);


                        }



                        ?>
                        <a href="<?php echo Url::base(); ?>index.php/label/detail?id=<?php echo $value; ?>"><?php echo  $label[0]['name']; ?></a>


                    <?php }?>

                </div>
            </div>
            <ul class="sp-info-r f-r">
                <?php

                foreach($pageproduct as $key=>$value){


                    if($value['type']==8) {
                        $getresult = $get->getCache('productId'.$value['productId']);

                        if($getresult==''){
                            $parm['id']=$value['productId'];
                            $getresult = $product->getByProductId($parm);



                        }

$getresult[0]['mainpic'] = $value['img'];
                        ?>

                        <li>
                            <div class="li-top">
                                <a href="<?php echo Url::base(); ?>index.php/product/detail?id=<?php  echo $getresult[0]['productId'];?>" class="li-top-tu"><img width="95" height="110" src="<?php echo Url::base(); ?>uploads/<?php echo$getresult[0]['mainpic'];?>" /></a>
                               <p class="jiage"><span class="sp1">￥<?php echo $getresult[0]['pricedefault'];?></span><span class="sp2">￥<?php echo $getresult[0]['OriginalPrice'];?></span></p>
                            </div>
                            <p class="miaoshu"><?php echo $getresult[0]['title'];?></p>
                            <div class="li-md">
                                <div class="md-l f-l">
                                    <p class="md-l-l f-l" ap="">1</p>
                                    <div class="md-l-r f-l">
                                        <a href="JavaScript:;" class="md-xs" at="">∧</a>
                                        <a href="JavaScript:;" class="md-xx" ab="">∨</a>
                                    </div>
                                    <div style="clear:both;"></div>
                                </div>
                                <div class="md-r f-l">
                                    <button class="md-l-btn1" attr="<?php echo $getresult[0]['id'];?>">立即购买</button>
                                    <button class="md-l-btn2">加入购物车</button>
                                </div>
                                <div style="clear:both;"></div>
                            </div>
                            <p class="pingjia"><?php echo $getresult[0]['replying'];?>评价</p>

                        </li>
                    <? }

                }
                ?>



            </ul>
            <div style="clear:both;"></div>
        </div>
        <div class="sp-con-info">
            <h3 class="sp-info-tit"><span style="color:#F56904;">5F</span></h3>
            <div class="sp-info-l f-l">
                <?php

                $labels = '';
                foreach($pageproduct as $key=>$value){
                    $labels = $value['content'];

                    if($value['type']==11){
                        ?>
                        <a href="<?php echo Url::base(); ?>index.php/product/detail?id=<?php echo$value['productId'];?>"><img width=231 height=464 src="<?php echo Url::base(); ?>uploads/<?php echo$value['img'];?>" /></a>

                        <?php
                        break;
                    }}
                $list = explode(',', $labels);
                ?>

                <div class="sp-l-b">

                    <?php

                    require_once ('application/classes/api/product.php');
                    require_once ('application/classes/api/label.php');
                    $entity = new label();
                    $product = new product();
                    foreach($list as $key=>$value){
                        $label = $get->getCache('label'.$value);
                        if($label == ''){
                            $parm['id'] =$value;
                            $label = $entity ->detail($parm);

                            $get->setCache('label'.$value,$label);


                        }



                        ?>
                        <a href="<?php echo Url::base(); ?>index.php/label/detail?id=<?php echo $value; ?>"><?php echo  $label[0]['name']; ?></a>


                    <?php }?>

                </div>
            </div>
            <ul class="sp-info-r f-r">
                <?php

                foreach($pageproduct as $key=>$value){


                    if($value['type']==9) {
                        $getresult = $get->getCache('productId'.$value['productId']);

                        if($getresult==''){
                            $parm['id']=$value['productId'];
                            $getresult = $product->getByProductId($parm);



                        }

$getresult[0]['mainpic'] = $value['img'];
                        ?>

                        <li>
                            <div class="li-top">
                                <a href="<?php echo Url::base(); ?>index.php/product/detail?id=<?php  echo $getresult[0]['productId'];?>" class="li-top-tu"><img width="95" height="110" src="<?php echo Url::base(); ?>uploads/<?php echo$getresult[0]['mainpic'];?>" /></a>
                               <p class="jiage"><span class="sp1">￥<?php echo $getresult[0]['pricedefault'];?></span><span class="sp2">￥<?php echo $getresult[0]['OriginalPrice'];?></span></p>
                            </div>
                            <p class="miaoshu"><?php echo $getresult[0]['title'];?></p>
                            <div class="li-md">
                                <div class="md-l f-l">
                                    <p class="md-l-l f-l" ap="">1</p>
                                    <div class="md-l-r f-l">
                                        <a href="JavaScript:;" class="md-xs" at="">∧</a>
                                        <a href="JavaScript:;" class="md-xx" ab="">∨</a>
                                    </div>
                                    <div style="clear:both;"></div>
                                </div>
                                <div class="md-r f-l">
                                    <button class="md-l-btn1"  attr="<?php echo $getresult[0]['id'];?>" >立即购买</button>
                                    <button class="md-l-btn2">加入购物车</button>
                                </div>
                                <div style="clear:both;"></div>
                            </div>
                            <p class="pingjia"><?php echo $getresult[0]['replying'];?>评价</p>

                        </li>
                    <? }

                }
                ?>



            </ul>
            <div style="clear:both;"></div>
        </div>

        <style>


            #fullbg {
                background-color:gray;
                left:0;
                opacity:0.5;
                position:absolute;
                top:0;
                z-index:3;
                filter:alpha(opacity=50);
                -moz-opacity:0.5;
                -khtml-opacity:0.5;
            }
            #dialog {
                background-color:#fff;
                border:5px solid rgba(0,0,0, 0.4);
                height:400px;
                left:50%;
                margin:-200px 0 0 -200px;
                padding:1px;
                position:fixed !important; /* 浮动对话框 */
                position:absolute;
                top:50%;
                width:400px;
                z-index:5;
                border-radius:5px;
                display:none;
            }
            #dialog p {
                margin:0 0 12px;
                height:24px;
                line-height:24px;
                background:#CCCCCC;
            }
            #dialog p.close {
                text-align:right;
                padding-right:10px;
            }
            #dialog p.close a {
                color:#fff;
                text-decoration:none;
            }

        </style>
        <script type="text/javascript">
            //显示灰色 jQuery 遮罩层

            $(function(){
                $('.md-l-btn1').click(function($key,$value){
                    $("#productId").val($(this).attr("attr"));
                    $("#number").val($(this).parent().parent().find('p').text())
                    $.ajax({

                        type: 'post',

                        url:  '<?php echo Url::base(); ?>index.php/product/getAll?productId='+$(this).attr("attr"),

                        data: {phone:$('#phone').val(),password:$("#password").val()} ,

                        success: function(data){
                            var bh = $("body").height();
                            var bw = $("body").width();
                            $("#fullbg").css({
                                height:bh,
                                width:bw,
                                display:"block"
                            });
                            $("#dialog").show();
                            $("#contentDiv").html(data);
                        },

                        dataType: 'html'

                    });
                })
            })
            //关闭灰色 jQuery 遮罩
            function closeBg() {
                $("#fullbg,#dialog").hide();
            }
        </script>
            <div id="fullbg"></div>
        <script type="text/javascript">
            function check(){

                 $.ajax({       data:{'model1':$("#model1").val(),'model2':$("#model2").val(),'model3':$("#model3").val(),'productId':$("#productId").val(),'number':$("#number").val()},

                                type: 'POST',
                                url: '<?php echo Url::base(); ?>index.php/product/checkSku',
                                success: function(data){
                                   if(data ==1){
                                    document.form1.submit()
                                   }else{
                                        alert("该商品库存不够")
                                   }
                                } ,
                                dataType: "html"

                            });
            }
        </script>
        <form name="form1" id="form1" method="post" action="<?php echo Url::base(); ?>index.php/product/order"  onsubmit="check()" >
            <div id="dialog">
                <p class="close"><a href="#" onclick="closeBg();">关闭</a></p>
                <div id="contentDiv">正在加载，请稍后....</div>
                <input type="hidden" value=""  name="productId[]" id="productId">
                <input type="hidden" value="" name="number[]" id="number">
                <input  value="提交"  type="button"   onclick="check()" />
                <input value="取消" type="button" onclick="closeBg()">

            </div>
        </form>
        </div>